import java.util.HashSet;
import java.util.Set;

/**
 * @author LKQ
 * @date 2022/2/25 16:55
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] a = {1,2,4};
        solution.subarrayBitwiseORs(a);
    }
    public int subarrayBitwiseORs(int[] A) {
        // 0 | a = a;
        Set<Integer> ans = new HashSet();
        Set<Integer> cur = new HashSet();
        cur.add(0);
        for (int x: A) {
            // cur 中刚开始只有0，
            Set<Integer> cur2 = new HashSet();
            // cur2加入， 当前x与cur中所有元素或的值
            for (int y: cur) {
                cur2.add(x | y);
            }
            // 加入x本身
            cur2.add(x);
            cur = cur2;
            ans.addAll(cur);
        }

        return ans.size();
    }
}
